
//
//  PhoneViewController.m
//  Lovely Food
//
//  Created by 李经纬 on 15/12/8.
//  Copyright © 2015年 李经纬. All rights reserved.
//

#import "PhoneViewController.h"
#import <AVOSCloud.h>

@interface PhoneViewController ()

@property (nonatomic, strong) UITextField *phoneTextField;
@end

@implementation PhoneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 69, self.view.frame.size.width, 40)];
    self.phoneTextField.layer.borderWidth = 1;
    self.phoneTextField.layer.borderColor = [[UIColor grayColor] CGColor];
    self.phoneTextField.clearButtonMode = UITextFieldViewModeAlways;
    self.phoneTextField.text = self.phoneStr;
    self.phoneTextField.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.phoneTextField];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:(UIBarButtonItemStyleDone) target:self action:@selector(rightAction:)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor yellowColor];
}

- (void)rightAction:(UIBarButtonItem *)sender
{
    AVUser *currnet = [AVUser currentUser];
    [currnet setObject:self.phoneTextField.text forKey:@"phone"];
    [currnet saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
